package com.mzy.olddate.demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author Ives
 * * @date 2021/9/2
 */
public class Demo {
  public static void main(String[] args) {
//    String oldColCode="010700,010700010,010700010010,010700020,010700020010,010700030,010700030010,010700030010010,010700030010020,010700030010030,010700040,010700040010,010700040020,010700050,010700050010,010700060,010700060010,010700060020,010700060030,010700060040,010700080,010700090,010700100,010700100010,010700100020,010700150,010700160,010700160010,010700160020,010700160040,010700160050,010700160060,010700160070,010700160080,010700160090,010700160090010,010700160090020,010700160090030,010700160090040,020990990980,020990990990010,020990990990020,020990990990030,020990990990040,020990990990050,020990990990060,020990990990070,020990990990080,020990990990090,020990990990160,020990990990170,020990990990180,020990990990190,020990990990200,020990990990210,020990990990230,020990990990240,020990990990250,020990990990990010,020990990990990020,020990990990990040,020990990990990060,020990990990990070";
//    String oldColCode="010700010,010700010010,010700020,010700020010,010700030,010700030010,010700030010010,010700030010020,010700030010030,010700040,010700040010,010700040020,010700050,010700050010,010700060,010700060010,010700060020,010700060030,010700060040,010700080,010700090,010700100,010700100010,010700100020,010700150,010700160,010700160010,010700160020,010700160040,010700160050,010700160060,010700160070,010700160080,010700160090,010700160090010,010700160090020,010700160090030,010700160090040,020990990980,020990990990010,020990990990020,020990990990030,020990990990040,020990990990050,020990990990060,020990990990070,020990990990080,020990990990090,020990990990160,020990990990170,020990990990180,020990990990190,020990990990200,020990990990210,020990990990230,020990990990240,020990990990250,020990990990990010,020990990990990020,020990990990990040,020990990990990060,020990990990990070";
//    String adcCode = "0020130700910000000000010,0020130700910000000000020,0020130700910000000000030,0020130700910000000000040,0020130700910000000000050,0020130700910000000000060,0020130700910000000000070,0020130700910000000000080,0020130700910000000000090,0020130700910000000000100,0020130700910000000000110,0020130700910000000000120,0020130700910000000000130,0020130700910000000000140,0020130700910000000000150,0020130700910000000000160,0020130700910000000000170,0020130700910000000000180,0020130700910000000000190,0020130700910000000000200,0020130700910000000000210,0020130700910000000000220,0020130700910000000000230,0020130700910000000000240";
    String advCode = "020130700910000000000020,020130700910000000000190,020130700910000000000130,020130700910000000000150,020130700910000000000230,020130700910000000000100,020130700910000000000210,020130700910000000000140,020130700010000001000020,020130700910000000000180,020130700910000000000170,020130700910000000000110,020130700910000000000160,020130700910000000000120,020130700910000000000200,020130700910000000000220,020130700910000000000010,020130700910000000000240";
    String[] split = advCode.split(",");
    List<String> strings = Arrays.asList(split);



    String webCode = "700";
    String envCode = "910";
//    colPrint(strings,envCode);
//    advPrint(strings,envCode);
    aa(strings);
  }

  public static void aa(List<String> strings){
    String demo ="update CMS_DRAFT_COLUMN_INFO set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_COLUMN_INFO set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_DRAFT_COL_GROUP_PERM set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_DRAFT_NEWS_BASE_INFO set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_NEWS_BASE_INFO set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_DRAFT_NEWS_CONTENT set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_NEWS_CONTENT set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
            "update CMS_PAGE_COLUMN_SIGN set COLUMN_CODE='XXYY' where COLUMN_CODE='AABB';";
    ArrayList<String> list = new ArrayList<>();
    for(String s : strings){
      String substring = s;
      String substring1 = s.substring(0, 12);
      String substring2 = s.substring(s.length() - 3);
      String string2 = substring1 + "010010010" + substring2;
//      System.out.println(substring);
      String aabb = demo.replaceAll("AABB", s);

      String xxyy = aabb.replaceAll("XXYY", string2);
      list.add(xxyy);
    }

    for (String item:list
    ) {
      System.out.println(item);
    }
  }

  public static void advPrint(List<String> strings,String envCode){

    String advDemo="020130700"+ envCode;
    Integer num = 10;
    ArrayList<String> list = new ArrayList<>();
    for (String item:strings) {
      String demo ="update CMS_DRAFT_COLUMN_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_COLUMN_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_COL_GROUP_PERM_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_NEWS_BASE_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_NEWS_BASE_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_NEWS_CONTENT_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_NEWS_CONTENT_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_PAGE_COLUMN_SIGN_5G set COLUMN_CODE='XXYY' where COLUMN_CODE='AABB';";
      if (item.startsWith("020")){
        String numStr = String.valueOf(num);

        String pattern="000000000000";
        String aa = pattern.substring(0, pattern.length()-numStr.length())+numStr;

        String s1 = advDemo + aa;


        String aabb = demo.replaceAll("AABB", item);
        String xxyy = aabb.replaceAll("XXYY", s1);
//        System.out.println(s1);
        list.add(xxyy);
        num = num + 10;
      }
    }

    for (String item:list
    ) {
      System.out.println(item);
    }
  }

  /**
   *
   * @param strings
   * @param envCode
   */
  public static void colPrint(List<String> strings,String envCode){
    ArrayList<String> list = new ArrayList<>();
    for (String item:strings) {
      String demo ="update CMS_DRAFT_COLUMN_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_COLUMN_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_COL_GROUP_PERM_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_NEWS_BASE_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_NEWS_BASE_INFO_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_DRAFT_NEWS_CONTENT_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_NEWS_CONTENT_5G set COL_CODE='XXYY' where COL_CODE='AABB';\n" +
              "update CMS_PAGE_COLUMN_SIGN_5G set COLUMN_CODE='XXYY' where COLUMN_CODE='AABB';";
      if (item.startsWith("010")){
        String substring = item.substring(0, 6);
        String substring1 = item.substring(6);
        String sum = substring + envCode + substring1;
        String aabb = demo.replaceAll("AABB", item);
        String xxyy = aabb.replaceAll("XXYY", sum);
//        System.out.println(sum);
        list.add(xxyy);
      }
    }

    for (String item:list
    ) {
      System.out.println(item);
    }
  }


}
